<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>温湿度数据写入管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		
		$(document).ready(function() {
		
			//设置当前层级	
			if('${nowLevel}' != ""){
				$("#nowLevel").html("[" + "${nowLevel}" + "]");
			}
		});
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        
        //历史数据导出Excel文件
		function expExcelData(){
			var submit = function (v, h, f) {
			    if (v == 'ok'){
			        $("#searchForm").attr("action","${ctx}/ccsenhumidata/sensorHumiData/expExcelData");
					$("#searchForm").submit();
			    }
			    $("#searchForm").attr("action","${ctx}/ccsenhumidata/sensorHumiData");
			    return true; //close
			};
			
			$.jBox.confirm("确定导出历史数据吗？", "提示", submit);
		}
		
		function closeTree(){
			var openCloseDiv = document.getElementById('openClose'); 
			openCloseDiv.click();
		}
	</script>
	
	<style type="text/css">
		.active{
			color: #000000;
		}
		body{
			color: #000000;
		}
		#exportBtn{
			width: 75px;
		}
		#officeContent{
			border: none;
		}
		#nowLevel{
			color: #000;
		}
	</style>
</head>
<body>
	<div id="content" class="row-fluid">
		<div id="left">
			<div class="accordion-heading">
				<a class="accordion-toggle">组织树
					<i id="colseBtn" class="icon-remove pull-right" onclick="closeTree();"></i>
					<label id="nowLevel"></label>
				</a>
			</div>
			<iframe id="officeContent" src="${ctx}/cchierarchy/hierarchy/list" width="100%" height="100%" frameborder="0"></iframe>
		</div>
		<div id="openClose" class="close">&nbsp;</div>
		<div id="right">
			<ul class="nav nav-tabs">
				<li class="active"><a href="${ctx}/ccsenhumidata/sensorHumiData/">历史数据查询</a></li>
				<shiro:hasPermission name="ccsenhumidata:sensorHumiData:edit"><li><a href="${ctx}/ccsenhumidata/sensorHumiData/form">温湿度数据写入添加</a></li></shiro:hasPermission>
			</ul>
			<form:form id="searchForm" modelAttribute="sensorHumiData" action="${ctx}/ccsenhumidata/sensorHumiData" method="post" class="breadcrumb form-search">
				<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
				<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<ul class="ul-form">
					<li style="margin-top: 2px;">传感器名称</li>
					<li style="font-size:12px; margin-left: 10px;">
						<form:select  path = "sensorMac" class="span2 minWidth">  
				  			<form:option value="" label="">--请选择--</form:option>
				  			<c:forEach var="item" items="${sensorMacList}">
								<form:option value="${item.MAC}" itemLabel="label" itemValue="value" htmlEscape="false">${item.NAME}</form:option>
							 </c:forEach> 
				 		</form:select>
				 	
		 			</li>
		 			<li style="margin-left: 15px;">温度状态</li>
		 			<li style="font-size:12px; margin-left: 10px; ">
						<form:select  path = "tempIsnormal" class="span2 minWidth">  
				  			<form:option value="" label="">--请选择--</form:option>
				  			 <c:forEach var="item" items="${sensorTempList}">
								<form:option value="${item.TEMPSTATUS}" itemLabel="label" itemValue="value" htmlEscape="false">${item.TEMPSTATUS}</form:option>						
							 </c:forEach>
				 		</form:select>
		 			</li>
					<li style="margin-left: 15px;">开始时间</li>
			 		<li style="margin-left: 10px; margin-top: -2px;"> <input type="text" id="startTime" name="startTime" style="width: 190px;" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="${sensorHumiData.startTime}" /> </li>
					<li style="margin-left: 15px;">结束时间</li>
			 		<li style="margin-left: 10px; margin-top: -2px;"> <input type="text" id="endTime" name="endTime" style="width: 190px; margin-left: 5px;" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="${sensorHumiData.endTime}" /> </li>  
					<li style="margin-top: -2px; margin-left: 15px;"> <input type="submit" id="searchBtn"  class="btn btn-primary" value="查询"></input> </li>
					<li style="margin-top: -2px; margin-left: 5px;"> <input id="exportBtn"  class="btn btn-primary" value="导出EXCEL" onclick="expExcelData()"></input> </li>
					<li class="clearfix"></li>
				</ul>
			</form:form>
			<sys:message content="${message}"/>
			<table id="contentTable" class="table table-striped table-bordered table-condensed">
				<thead>
					<tr style="width:200px; height:30px;">
						<th>传感器编号</th>
						<th>测量时间</th>
						<th>温度°C</th>
						<th>温度状态</th>
						<th>湿度%</th>
						<!-- <th>湿度状态</th> -->
						<th>数据状态</th>
						<shiro:hasPermission name="ccsenhumidata:sensorHumiData:edit"><th>操作</th></shiro:hasPermission>
					</tr>
				</thead>
				<tbody>
				<c:forEach items="${page.list}" var="sensorHumiData">
					<tr style="width:200px; height:30px;">
						<td>
							${sensorHumiData.sensorMac}
						</td>
						<td>
							<fmt:formatDate value="${sensorHumiData.getTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
						</td>
						<td>
							${sensorHumiData.tempBcd}
						</td>
						<td>
							${sensorHumiData.tempIsnormal}
						</td>
						<td>
							${sensorHumiData.humiBcd}
						</td>
						<td>
							${sensorHumiData.deviceStatus}
						</td>
						<shiro:hasPermission name="ccsenhumidata:sensorHumiData:edit"><td>
		    				<a href="${ctx}/ccsenhumidata/sensorHumiData/form?id=${sensorHumiData.id}">修改</a>
							<a href="${ctx}/ccsenhumidata/sensorHumiData/delete?id=${sensorHumiData.id}" onclick="return confirmx('确认要删除该温湿度数据写入吗？', this.href)">删除</a>
						</td></shiro:hasPermission>
					</tr>
				</c:forEach>
				</tbody>
			</table>
			<div class="pagination">${page}</div>
		</div>
	</div>
	
	<script type="text/javascript">
	   		
		var leftWidth = "350"; // 左侧窗口大小
		var htmlObj = $("html"), mainObj = $("#main");
		var frameObj = $("#left, #openClose, #right, #right iframe");
		function wSize(){
			var strs = getWindowSize().toString().split(",");
			/* htmlObj.css({"overflow-x":"hidden", "overflow-y":"hidden"}); */
			mainObj.css("width","auto");
			frameObj.height(strs[0] - 5);
			var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
			$("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5);
			$(".ztree").width(leftWidth - 10).height(frameObj.height() - 46);
		}
	</script>
	<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>
	
</body>
</html>